package ali_oss

import (
	"context"
	"nearby/biz/dal/db/repo"
	"strings"
)

var (
	NearbyBucket = "nearbyuni"
)

func InitOSS() {
	ctx := context.Background()
	conf.Init(ctx)
}

type OSSConfig struct {
	Endpoint        string `json:"endpoint"`
	AccessKeyID     string `json:"access_key_id"`
	AccessKeySecret string `json:"access_key_secret"`
}

var conf = &OSSConfig{}

func (c *OSSConfig) Init(ctx context.Context) {
	kvRepo := repo.NewBizKVRepo(ctx)
	v := kvRepo.GetVal(ctx, "oss_conf")
	vv := strings.Split(v, ",")
	conf.Endpoint = vv[0]
	conf.AccessKeyID = vv[1]
	conf.AccessKeySecret = vv[2]
}
